﻿using System.Drawing;
using System.Windows.Forms;

namespace WindowsAPI
{
    public partial class CustomBorderForm : Form
    {
        const int WM_NCPAINT = 0x85;

        public CustomBorderForm()
        {
            // This could be called from main.
            User32.DisableProcessWindowsGhosting();

            InitializeComponent();
        }

        //protected override void OnHandleCreated(EventArgs e)
        //{
        //    //Windows.API.SetWindowTheme(Handle, "", "");
        //    base.OnHandleCreated(e);
        //}

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            switch(m.Msg)
            {
                case WM_NCPAINT:
                    {
                        var hDC = User32.GetWindowDC(m.HWnd);
                        using(var g = Graphics.FromHdc(hDC))
                            g.FillEllipse(Brushes.Red, new Rectangle((Width - 20) / 2, 8, 20, 20));
                        User32.ReleaseDC(m.HWnd, hDC);
                    }
                    break;
            }
        }
    }
}
